T
Chili.Opf3 Send comments on this topic.
Generic GetObjectReader(String,Object[]) Method
See Also  Example
Chili.Opf3 Namespace > ObjectContext Class > GetObjectReader Method : Generic GetObjectReader(String,Object[]) Method




conditions
A condition string that specifies the objects that are loaded.
parameter
A list of parameter that is passed as parameter for the conditions.
Creates and executes an ObjectReader on the ObjectContext.

Syntax

Visual Basic (Declaration) 
Overloads Public Overridable Function GetObjectReader(Of T)( _
   ByVal conditions As String, _
   ByVal ParamArray parameter() As Object _
) As ObjectReader(Of T)
Visual Basic (Usage)Copy Code
Dim instance As ObjectContext
Dim conditions As String
Dim parameter() As Object
Dim value As ObjectReader(Of T)
 
value = instance.GetObjectReader(Of T)(conditions, parameter)
C# 
public virtual ObjectReader<T> GetObjectReader<T>( 
   string conditions,
   params object[] parameter
)
Managed Extensions for C++ 
public: virtual ObjectReader<T>* GetObjectReader<T>( 
   string* conditions,
   params Object*[]* parameter
) 
C++/CLI 
public:
virtual ObjectReader<T>^ GetObjectReadergeneric<typename T>
( 
   String^ conditions,
   ... array<Object^>^ parameter
) 

Parameters

conditions
A condition string that specifies the objects that are loaded.
parameter
A list of parameter that is passed as parameter for the conditions.

Type Parameters

T

Return Value

An ObjectReader representing a forward-only cursor on the resultset.

Example

The following example introduces the use of the GetObjectReader routine.
C#Copy Code
// Creates a new ObjectContext that uses an MsSql Server as storage. 
ObjectContext context = new ObjectContext(new MsSqlStorage("sa", "",  
    "localhost", "application")); 
  
// ... Other code. 
  
// Gets all object matching the name and sorting them by name. 
// Returns the objects in an ObjectReader. 
ObjectReader<User> reader = context.GetObjectReader<User> 
    ("Name like {0} SortBy Name Asc", "%mith%"); 
  
while(reader.Read()) 

    User user = reader.Current; 
    // Do something. 

  
// ObjectReader supports also foreach 
// foreach(User user in reader) 
// { 
//       // Do something. 
// } 
    

Remarks

This routine returns an ObjectReader that is a forward-only cursor through the resultset. The ObjectReader allows you to go through the resultset object per object. Usually an ObjectReader is used in export or batch routines to minimize the memory amount.

Requirements

Platforms: Windows 2000, Windows XP family, Windows Server 2003 family, Windows Vista family

See Also